/*    */ package handling.channel.handler;
/*    */ 
/*    */

import client.MapleClient;
import client.inventory.Equip;
import client.inventory.Item;
import client.inventory.MapleInventoryType;
import constants.ItemConstants;
import server.MapleInventoryManipulator;
import server.MapleItemInformationProvider;
import tools.MaplePacketCreator;
import tools.Randomizer;
import tools.data.input.LittleEndianAccessor;
import tools.packet.MTSCSPacket;

/*    */
/*    */
/*    */
/*    */
/*    */
/*    */
/*    */
/*    */
/*    */
/*    */

/*    */
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class UseHammerHandler
/*    */ {
/*    */   public static void UseHammer(LittleEndianAccessor slea, MapleClient c) {
/* 35 */     slea.readInt();
/* 36 */     int hammerSlot = slea.readInt();
/* 37 */     int hammerItemid = slea.readInt();
/* 38 */     slea.readInt();
/* 39 */     int equipSlot = slea.readInt();
/* 40 */     Item useItem = c.getPlayer().getInventory(MapleInventoryType.USE).getItem((short)hammerSlot);
/* 41 */     Equip toItem = (Equip)c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((short)equipSlot);
/*    */     
/* 43 */     if (useItem == null || useItem.getQuantity() <= 0 || useItem.getItemId() != hammerItemid || c.getPlayer().hasBlockedInventory()) {
/* 44 */       c.announce(MaplePacketCreator.enableActions());
/*    */       return;
/*    */     } 
/* 47 */     MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
/* 48 */     if (toItem != null) {
/* 49 */       if (ItemConstants.canHammer(toItem.getItemId()) && ii.getSlots(toItem.getItemId()) > 0 && toItem.getViciousHammer() < 2) {
/* 50 */         toItem.setViciousHammer((byte)(toItem.getViciousHammer() + 1));
/* 51 */         int successRate = MapleItemInformationProvider.getInstance().getScrollSuccess(hammerItemid);
/* 52 */         if (c.getPlayer().isShowPacket()) {
/* 53 */           c.getPlayer().dropSpouseMessage(11, "黄金锤提炼 - 成功几率: " + successRate + "%");
/*    */         }
/* 55 */         if (Randomizer.nextInt(100) < successRate) {
/* 56 */           toItem.setUpgradeSlots((byte)(toItem.getUpgradeSlots() + 1));
/* 57 */           c.announce(MTSCSPacket.INSTANCE.sendGoldHammerResult(0, 0));
/*    */         } else {
/* 59 */           c.announce(MTSCSPacket.INSTANCE.sendGoldHammerResult(1, 0));
/*    */         } 
/* 61 */         c.getPlayer().forceUpdateItem((Item)toItem);
/* 62 */         MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short)(byte)hammerSlot, (short)1, false, true);
/*    */       } else {
/* 64 */         c.getPlayer().dropMessage(5, "无法使用黄金锤提炼的物品。");
/* 65 */         c.announce(MTSCSPacket.INSTANCE.sendGoldHammerResult(2, 1));
/*    */       } 
/*    */     }
/*    */   }
/*    */ 
/*    */   
/*    */   public static void HammerResponse(LittleEndianAccessor slea, MapleClient c) {
    c.announce(MTSCSPacket.INSTANCE.sendCashHammerResult(false, slea.readInt() == 0xB7));
/*    */   }
/*    */   
/*    */   public static void GoldHammerResponse(LittleEndianAccessor slea, MapleClient c) {
/* 77 */     c.announce(MTSCSPacket.INSTANCE.sendGoldHammerResult(2, slea.readInt()));
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\handling\channel\handler\UseHammerHandler.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */